
const defaultState = {
    inputValue:'jsPang',
    list:[]
}

export default (state = defaultState, action) => {

    let newState = JSON.parse(JSON.stringify(state))
    if (action.type == 'change_input') {
        newState.inputValue = action.value
        return newState
    }

    if (action.type == 'add_item') {
        newState.list.push(newState.inputValue)
        newState.inputValue = ''
        return newState
    }

    if (action.type == 'del_item') {
        newState.list.splice(action.index,1)
        return newState
    }


    return state
}